package com.bamanker.cloudconsumer.feign;

import com.bamanker.cloudapi.domain.toEmail;
import com.bamanker.cloudapi.model.error.CommonErrorCode;
import com.bamanker.cloudapi.model.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;

/**
 * @author bamanker
 */
@Slf4j
//@Component
public class EmailFeignClientFallback implements EmailClient{
    @Override
    public Object list(int start, int size) {
        log.error("调用接口 /toEmails 失败，参数：start={}，size={}", start,size);
        //return "OpenFeign 降级";
        throw new BusinessException(CommonErrorCode.UNKNOWN_ERROR, CommonErrorCode.UNKNOWN_ERROR.getMessage());
    }

    @Override
    public Object get(int id) {
        log.error("调用接口 /toEmails 失败，参数：id={}", id);
        //return "OpenFeign 降级";
        throw new BusinessException(CommonErrorCode.UNKNOWN_ERROR, CommonErrorCode.UNKNOWN_ERROR.getMessage());
    }

    @Override
    public Object add(toEmail t) {
        log.error("调用接口 /toEmails 失败，参数：Object={}",t);
        //return "OpenFeign 降级";
        throw new BusinessException(CommonErrorCode.UNKNOWN_ERROR, CommonErrorCode.UNKNOWN_ERROR.getMessage());
    }

    @Override
    public Object delete(Long id) {
        log.error("调用接口 /toEmails 失败，参数：Object={}",id);
        //return "OpenFeign 降级";
        throw new BusinessException(CommonErrorCode.UNKNOWN_ERROR, CommonErrorCode.UNKNOWN_ERROR.getMessage());
    }

    @Override
    public Object update(toEmail t) {
        log.error("调用接口 /toEmails 失败，参数：Object={}",t);
        //return "OpenFeign 降级";
        throw new BusinessException(CommonErrorCode.UNKNOWN_ERROR, CommonErrorCode.UNKNOWN_ERROR.getMessage());
    }
}
